Skip to content

feat(analytics): add configureAutoTrack support for Kinesis and Kinesis Firehose#14854

Merged
soberm merged 4 commits into
mainfrom
feat/analytics-kinesis-autotrack
Jul 14, 2026
Merged

feat(analytics): add configureAutoTrack support for Kinesis and Kinesis Firehose#14854
soberm merged 4 commits into
mainfrom
feat/analytics-kinesis-autotrack

Conversation

@soberm

@soberm soberm commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description of changes

Adds configureAutoTrack (auto-tracking) support to the Kinesis and Kinesis Firehose Analytics providers. Auto-tracking (session / pageView / event trackers) previously existed only for Pinpoint; this brings the same capability to the two stream providers.

This change is purely additive — Pinpoint behavior is unchanged.

What it adds

  • configureAutoTrack(input) for both providers, mirroring the existing Pinpoint implementation (module-level configuredTrackers singleton, updateProviderTrackers + validateTrackerConfiguration, session/pageView/event tracker types).
  • Each auto-tracked event is forwarded to the provider's record() API with the data shape { name: eventName, attributes } (mirrors PinpointAnalyticsEvent).
  • Per-tracker-type stream configuration: streamName (and partitionKey for Kinesis) are supplied in each configureAutoTrack call's options, so different tracker types can target different streams. Reconfiguring a tracker updates its stream coordinates.
  • New input types: KinesisConfigureAutoTrackInput / KinesisFirehoseConfigureAutoTrackInput and their Session/PageView/Event tracking-option types, exported from each provider's public entry point.

Kinesis Firehose difference: Firehose has no partitionKey, so its options only carry streamName and its record() call omits partitionKey.

Shared-infra decouple

  • utils/trackerHelpers.ts now types updateProviderTrackers against the generic AnalyticsConfigureAutoTrackInput (from ../types/inputs) instead of the Pinpoint-specific ConfigureAutoTrackInput. Pinpoint's type is a structural alias of the generic one, so Pinpoint continues to compile and behave identically.

Runtime validation (options stay optional in the type; validated at runtime)

  • Both providers throw AnalyticsValidationErrorCode.NoStreamName when enable: true and streamName is missing.
  • Kinesis additionally throws AnalyticsValidationErrorCode.NoPartitionKey when enable: true and partitionKey is missing.
  • No validation fires when enable: false.

React Native is unchanged — both providers inherit the existing shared validator that restricts auto-tracking to session on native.

Issue #, if available

N/A

Description of how you validated changes

  • Analytics unit tests: full package suite passes — 29 suites, 102 tests. New suites:
    • __tests__/providers/kinesis/apis/configureAutoTrack.test.ts
    • __tests__/providers/kinesis-firehose/apis/configureAutoTrack.test.ts
    • __tests__/utils/trackerHelpers.test.ts (proves updateProviderTrackers accepts a generic, non-Pinpoint input and forwards options; provider-specific fields are ignored by the shared trackers)
    • Coverage: validateTrackerConfiguration invoked; NoStreamName / NoPartitionKey thrown when enabling without the required fields; no throw when disabling; session/pageView/event trackers fire and call record() with the correct { streamName[, partitionKey], data: { name, attributes } }; reconfigure updates stream coordinates; disable cleans trackers up.
  • aws-amplify exports test: passes — 14 tests. exports.test.ts updated so the Kinesis and Kinesis Firehose expected-export arrays include configureAutoTrack.
  • TypeScript: tsc --noEmit -p tsconfig.build.json is clean (exit 0), no new errors and no Pinpoint regressions.
  • ESLint: all new/modified files are clean.

Checklist

  • PR description included
  • yarn test passes
  • Unit Tests are changed or added
  • Relevant documentation is changed or added (and PR referenced)

Checklist for repo maintainers

  • Verify E2E tests for existing workflows are working as expected or add E2E tests for newly added workflows
  • New source file paths included in this PR have been added to CODEOWNERS, if appropriate

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@soberm soberm requested a review from a team as a code owner July 1, 2026 13:49
@changeset-bot

changeset-bot Bot commented Jul 1, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: b3b9268

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@aws-amplify/analytics Minor
aws-amplify Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Comment thread packages/analytics/src/providers/kinesis/apis/configureAutoTrack.ts Outdated

@bobbor bobbor left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed — looks good to me. The concurrent multi-provider PageViewTracker concern from the first round (shared sessionStorage key + stacked history proxies) is correctly resolved via per-provider key namespacing and the ref-counted global history patch, with solid regression coverage. Approving.

@soberm soberm merged commit eed1462 into main Jul 14, 2026
41 checks passed
@soberm soberm deleted the feat/analytics-kinesis-autotrack branch July 14, 2026 13:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants